home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Games of Daze
/
Infomagic - Games of Daze (Summer 1995) (Disc 1 of 2).iso
/
x2ftp
/
msdos
/
mxcode
/
sndblst4
/
speaker.doc
< prev
next >
Wrap
Text File
|
1993-12-11
|
2KB
|
50 lines
In Windows/DOS Developer's Journal December 1991, Robert Bybee wrote an
article entitled 'Writing For The PC Speaker'. The program SPEAKER.EXE
is a butchered version of his program.
-The physics:
The PC can write individual levels to the speaker directly (a 1 or a 0).
It is also true that the PC can write these bits much faster than the speaker
can respond to them. At these speeds, the speaker becomes an integrator.
-1-Bit DACs:
The latest craze in CD Players is 1-Bit dacs. What is it? Well...a
1-bit DAC really is not a DAC at all. The sample is dithered (I will use
that term from here on out, even if it is wrong) with a bit pattern whose
integral (assume NRZL square wave) matches the level of the sample. This
n-length bit pattern is sent one bit at a time into an integrator at a bit
rate of n (pattern length) times the sample rate. From the integrator to the
pre-amp to the amp, etc...
For example a 3-bit sample would require 8 discrete levels, which would
require a 7-bit dither pattern:
dither input
1111111 <-- 111
1110111 <-- 110
1101101 <-- 101
1010101 <-- 100
0101010 <-- 011
0010010 <-- 010
0001000 <-- 001
0000000 <-- 000
-Good quality PC Speaker sound:
Why not use the PC Speaker as an integrator for a 1-bit DAC? Turns out to give
pretty good quality sound. The example program does not attempt to find out
how fast your particular machine is. You must adjust the bit pattern length
until it sounds right, or figure it out the machine speed yourself. With my
486DX2-66 I was running so fast that the speaker was overwhelmed and the volume
was very low. Adding a few NOPs to the end of the ophigh[] and oplow[] strings
should slow it down some. This will give fewer bits per second which will give
better volume, but worse quality.
-Disclaimer:
This is not something I am going to develop further.